<?php
try{
    $dsn = 'mysql:host=localhost;dbname=shumei19;charset=utf8';
    $pdo = new PDO($dsn, 'root', '654321');
    $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
    // 插入三条数据 提高效率
//    $sql = 'insert into users(username, password) values (?, ?)';
//    $stmt = $pdo->prepare($sql);
//    $result = $stmt->execute(['d', '123']);
//    $result = $stmt->execute(['b', '123']);
//    $result = $stmt->execute(['c', '123']);
//    var_dump($result);
//    $sql = 'insert into users(username, password) values (:username, :password)';
//    $stmt = $pdo->prepare($sql);
//    $stmt->execute([
////        ':username' => 'e',
////        ':password' => '666'
////    ]);
//    $stmt->bindValue(':username', 'f');
//    $stmt->bindValue(':password', '333');
//    $stmt->execute();
//    $sql2 = 'insert into users(username, password) values ("b", "321")';
//    $sql3 = 'insert into users(username, password) values ("c", "222")';
//    $pdo->exec($sql);
//    $pdo->exec($sql2);
//    $pdo->exec($sql3);

    $sql = 'select * from users where id > :id';
    $stmt = $pdo->prepare($sql);
    $stmt->bindValue(':id', 5);
    $stmt->execute();
    $result = $stmt->fetchAll();
    print_r($result);
}catch (PDOException $e) {
    exit($e->getMessage());
}